﻿
if (Masque && !Masque.T) {
    Masque.T = {
        isEmpty: function(_string){
            return !(Masque.V.isString(_string) && "" != _string);
        },
        HighLight: function(_tag, _attr, _attrValue, _words, _style){
            if (!document.createElement) {
                return;
            }
             if (Masque.T.isEmpty( _words)||Masque.T.isEmpty( _tag) ) 
                return;  
				        var prefix;
            if (!Masque.T.isEmpty(_style)) {
                prefix = "<span class='" + _style + "'>";
            }
            else {
                prefix = "<span style='color:red'>";
            }
            
            var l = document.getElementsByTagName(_tag);

            words = unescape(_words.replace(/\+/g, ' ')).split(" ");
            
            for (var w = 0; w < words.length; w++) {
                for (i = 0; i < l.length; i++) {
                    var el = l[i];
                    if (!Masque.T.isEmpty(_attr) && el.getAttribute(_attr) == _attrValue) {
                        var pa = new RegExp("(" + words[w] + ")", "ig");
                        el.innerHTML = el.innerHTML.replace(pa, prefix + "$1</span>");
                       
                        
                    }
                }
            }
        },
        GetHiddenValue: function(_result, _name){
			if (_result == null || typeof(_result) != "string") 
				return "";
			if (_name == null || typeof(_name) != "string") 
				return "";
			if (_result.length > _name.length + 8) {
				if (_result.indexOf("<!--" + _name + ":") != -1) {
					var startIndex = _result.indexOf("<!--" + _name + ":") + _name.length + 5;
					return _result.substring(startIndex, _result.indexOf("-->", startIndex));
				}
				
			}
			return "";
		}
        
    };
}
